//
//  BaseTableViewController.m
//  ObjectCProject
//
//  Created by lvfeijun on 2021/5/24.
//

#import "BaseTableViewController.h"

@interface BaseTableViewController ()

@property UITableView *tableView;

@end

@implementation BaseTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.datas = [self getDatas];
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    self.tableView = tableView;
}

-(NSArray *)getDatas{
    return self.datas;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.datas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifi"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identifi"];
    }
    cell.textLabel.text = self.datas[indexPath.row];
    return cell;
}

-(void)tableViewSelcctedAction:(NSIndexPath *)indexPath{
    NSString *methodName = self.datas[indexPath.row];
    SEL sel = NSSelectorFromString(methodName);
    if ([self respondsToSelector:sel]) {
//        Method method = class_getClassMethod(self.class, sel);
        [self performSelector:sel];
    }else{
        NSLog(@"没有找到该方法名： %@",methodName);
    }
}

-(void)tableViewSelcctedPush:(NSIndexPath *)indexPath{
    [self.navigationController pushViewController:[NSClassFromString(self.datas[indexPath.row]) new] animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
